<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 

class OrderModel extends BaseModel
{

    var $table  = 'company_order';	

    var $_page_rows = 10;	
	
    /* 插入数据 */
    function post($data)
    {    
	
		$time = time();     
    
		return $this->IU_Sql_Exe(array ('data' => array('user_id'=>"$data[user_id]",'company'=>"$data[company]",'name'=>"$data[name]",'sex'=>"$data[sex]",'telphone'=>"$data[telphone]",'cellphone'=>"$data[cellphone]",'address'=>"$data[address]",'email'=>"$data[email]",'content'=>"$data[content]",'add_time'=>"$time",'company_id'=>"$data[company_id]"), 'mode' => 'INSERT'));

        
    }

    function show($user_id = '')
    {   
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('conditions' =>"user_id = '{$user_id}' and status=1",'url' => '?app=order&act=orderlist'));		
		 $info['data'] = $this->S_Sql_Exe(array('fields' =>'id,company,name,sex,telphone,add_time','conditions' =>"user_id = '{$user_id}' and status=1",'order' =>'add_time desc','limit' =>$info['page']['sql_limit']));
    
		 return $info;
        
    }

    /* 插入数据 */
    function del($user_id = '',$id ='')
    {      
		return $this->D_Sql_Exe(array ('conditions' =>"user_id = '{$user_id}' and id = '{$id}' "));
        
    }

    /* 修改数据 */
    function editaction($user_id = '',$id ='',$data = '')
    {    
	    $time = time();
		return $this->IU_Sql_Exe(array ('data' => array('company'=>"$data[company]",'name'=>"$data[name]",'sex'=>"$data[sex]",'telphone'=>"$data[telphone]",'cellphone'=>"$data[cellphone]",'address'=>"$data[address]",'email'=>"$data[email]",'content'=>"$data[content]",'add_time'=>"$time"),'mode' => 'UPDATE','conditions' =>"user_id = '{$user_id}' and id = '{$id}' "));
        
    }

    /* 修改数据 */
    function editshow($user_id = '',$id ='')
    {    
	      
		 $info = $this->S_Sql_Exe(array('fields' =>'id,company,name,sex,telphone,cellphone,address,email,content','conditions' =>"user_id = '{$user_id}' and id='{$id}'",'return' =>'one'));
    
		 return $info;
        
    }




}








?>